When writing data to a disk array, it is desirable to define write operations that are atomic at some level. An atomic write operation is a write operation that cannot be broken into smaller parts. For example, there will not be a partial atomic write operation. Either the write operation occurs in full, or it does not occur at all.
The following example illustrates the importance of an atomic write operation. In the example, it is assumed that the atomic write operation covers 18 characters of data. The example is as follows:
1. User A writes “foofoofoofoofoofoo”.
2. User B writes “barbarbarbarbarbar”.
In this example, it is assumed that User A and User B are writing to the same location on a disk array. As a result, depending on the order of the operations and assuming that the write operation is atomic, a third user, User C, who reads the data from the location will either read “foofoofoofoofoofoo” or “barbarbarbarbarbar”. There is no possibility for User C to read “barbarbarfoofoofoo”.
One conventional method for implementing atomic writes to a disk array copies an entire file being written to from a first location on the disk array to a second location on the disk array, even when only a portion of the file is being modified. For example, if an application writes four bytes to a four megabyte file, this conventional method copies the four megabyte file from a first location on the disk array to a second location on the disk array. Modifications to the four megabyte file are made in the second location, referred to as the scratch location. If the application saves the changes, a pointer is updated to point to the second location. If a save operation does not occur, for example, because of a power interruption, the pointer is not updated, thus preserving the original file. Thus, atomic writes were conventionally preserved by copying the entire file from one location to another and only updating the pointer to point to the modified file when a save operation occurred.
One problem with this conventional method for preserving atomic writes is that it is inefficient to copy an entire file from one location on the disk array to another location on the disk array when only a portion of the file is being modified. Accordingly, there exists a need for improved methods, systems, and computer program products for preserving atomic writes to a disk array.